package org.wenhuayuan.project.main;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import org.wenhuayuan.library.util.HiStatusBar;
import org.wenhuayuan.project.common.uicomp.HiBaseActivity;
import org.wenhuayuan.project.main.logic.MainAtyLogic;

import java.util.List;

public class MainActivity extends HiBaseActivity implements MainAtyLogic.ActivityProvider {
    MainAtyLogic logic;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        HiStatusBar.INSTANCE.setStatusBar(this, true, Color.WHITE, false);

        logic = new MainAtyLogic(this, savedInstanceState);
//        ARouter.getInstance().build("/account/login").navigation();

//        Log.e("BizInterceptor", "Retrofit请求开始");
//        ApiFactory.INSTANCE.create(AccountApi.class).listCities("imooc")
//        .enqueue(new HiCallback<JSONObject>() {
//            @Override
//            public void onSuccess(@NotNull HiResponse<JSONObject> response) {
//                Log.e("BizInterceptor", "Retrofit请求成功");
//            }
//
//            @Override
//            public void onFailed(@NotNull Throwable throwable) {
//
//            }
//        });

    }


    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        logic.onSaveInstanceState(outState);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        List<Fragment> fragments = getSupportFragmentManager().getFragments();
        for (Fragment fragment: fragments) {
            fragment.onActivityResult(requestCode, resultCode, data);
        }
    }
}
